package com.weiaibenpao.demo.chislim.presenter;

import com.weiaibenpao.demo.chislim.base.BasePresenter;
import com.weiaibenpao.demo.chislim.bean.ChinaRecordBean;
import com.weiaibenpao.demo.chislim.retrofit.RetrofitUtils;
import com.weiaibenpao.demo.chislim.retrofit.rx.LoadingTransformer;
import com.weiaibenpao.demo.chislim.retrofit.rx.NetWorkTransformer;
import com.weiaibenpao.demo.chislim.retrofit.rx.SimpleObserver;
import com.weiaibenpao.demo.chislim.view.ChinaRecordView;

/**
 * Created by wlx on 2017/12/8.
 */

public class ChinaRecordPresenter extends BasePresenter<ChinaRecordView> {

    public void getRecord(int userId,int page,int pageSize){
        RetrofitUtils.getAPIService().getRecordList(userId,page,pageSize).
               compose(new NetWorkTransformer<ChinaRecordBean>())
                .compose(new LoadingTransformer<ChinaRecordBean>(mContext))
                .subscribe(new SimpleObserver<ChinaRecordBean>(mCompositeDisposable) {
                    @Override
                    public void call(ChinaRecordBean chinaRecordBean) {
                        getView().requestSuccess(chinaRecordBean);
                    }
                });
    }

}
